from radarssd_sql import *
import time
import random

if __name__ == "__main__":
    conn = connect_db()
    cursor = conn.cursor()

    #随机生成一个toa序列，查询后面origin_toa_length个信号
    TOA_length = 2048
    # pri_type_range = [1802175393,3604210499,5466294896,7267999178]
    # max_toa = pri_type_range[-1]-TOA_length
    #max_toa = 4*44738560 - TOA_length
    max_toa = 1*1000*1000 - TOA_length
    
    start_time = time.time()
    test_time = 1000

    for i in range(test_time):
        toa = random.randint(0,max_toa)
        cursor.execute(build_select_query(start_TOA=toa, limit=TOA_length))
        datas = cursor.fetchall()
        #print(datas)

    end_time = time.time()
    total_us = round(end_time-start_time,8)*1000000
    print("Total",total_us/1000000,"s, average",total_us/(TOA_length*test_time),"us/signal")